package org.loofer.ext.component.info;

import android.os.Environment;
import org.loofer.ext.Ext;
import org.loofer.ext.component.logger.Logger;

public class StorageDash {
    private static final String TAG = "StorageDash";

    public static boolean hasExternal() {
        try {
            return "mounted".equals(Environment.getExternalStorageState());
        } catch (Exception e) {
            Logger.w(TAG, "hasExternal exception" + e.toString());
            return false;
        }
    }

    public static boolean hasExternalReadable() {
        try {
            String state = Environment.getExternalStorageState();
            if ("mounted".equals(state) || "mounted_ro".equals(state)) {
                return true;
            }
            return false;
        } catch (Exception e) {
            Logger.w(TAG, "hasExternalReadable exception" + e.toString());
            return false;
        }
    }

    public static StorageInfo getExternalInfo() {
        if (hasExternalReadable()) {
            return StorageInfo.fromFile(Environment.getExternalStorageDirectory());
        }
        return null;
    }

    public static StorageInfo getInnerInfo() {
        return StorageInfo.fromFile(Ext.getContext().getFilesDir());
    }
}
